//
// Created by wze-zero on 2024/7/25 025.
//
#include<iostream>
#include <set>

using namespace std;

int main() {
    set<int> s;
    int n, m, num,flag=0;
    cin >> n >> m;
    int arr[m];
    for (int i = 0; i < n; ++i) {
        cin >> num;
        s.insert(num);
    }
    set<int> ::iterator it;
    for (int i = 0; i < m; ++i) {
        cin>>num;
        it=s.find(num);
        if (it==s.end()){
            s.insert(num);
            it=s.find(num);
            flag=1;
        }
        it++;
        if (it==s.end()){
            arr[i]=-1;
        } else{
            arr[i]=*it;
        }
        if (flag){
            flag=0;
            it--;
            s.erase(it);
        }
    }
    for (int i = 0; i < m; ++i) {
        cout << arr[i] << endl;
    }
    return 0;
}